import {request} from "./request";

export function goods_request(query,pageNum,pageSize) {
    return request({
        url:'/goods',
        method:'get',
        params:{
            query,
            pageNum,
            pageSize
        }
    })
}

export function goods_delete(id) {
    return request({
        url:'goods/delete/'+id,
        method:'get'
    })
}

export function file_delete(fileName) {
    return request({
        url:'file/delete',
        method:'post',
        params:{
            fileName
        }
    })
}

export function goods_submit(goodsInfo) {
    return request({
        url:'goods/submit',
        method:'post',
        data:{
            name:goodsInfo.name,
            imageUrl:goodsInfo.imageUrl,
            price:goodsInfo.price,
            nowPrice:goodsInfo.nowPrice,
            num:goodsInfo.num,
            typeId:goodsInfo.typeId,
            introduce:goodsInfo.introduce
        }
    })
}

export function goods_getById(id) {
    return request({
        url:'get/goods/byId/'+id,
        method:'get'
    })
}

export function goods_update(id,editInfo) {
    return request({
        url:'update/goods/'+id,
        method:'post',
        params:{
            id:id,
            imageUrl:editInfo.imageUrl,
            name:editInfo.name,
            price:editInfo.price,
            nowPrice: editInfo.nowPrice,
            num:editInfo.num,
            typeId:editInfo.typeId,
            introduce: editInfo.introduce
        }
    })
}